resource "aws_vpc" "this" {
  cidr_block = "10.0.0.0/16"
  tags       = {
    Stack : var.stack
  }
}

locals {
  esk_cluster_name = "${var.stack}-eks-cluster"
}
resource "aws_subnet" "public" {
  vpc_id                  = aws_vpc.this.id
  count                   = length(var.availability_zones)
  cidr_block              = cidrsubnet("10.0.0.0/16", 4, 8 + count.index)
  availability_zone       = "${var.region}${element(var.availability_zones, count.index)}"
  map_public_ip_on_launch = true

  tags = {
    Name                                              = "${var.stack}-${element(var.availability_zones, count.index)}-public-subnet"
    Stack                                             = var.stack
    "kubernetes.io/cluster/${local.esk_cluster_name}" = "shared"
    "kubernetes.io/role/elb"                          = 1
  }
  depends_on = []
}
